{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. The Multiple Roles of Anticipation in Developmental Robotics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Replicating the experiments in https://www.aaai.org/Papers/Symposia/Fall/2005/FS-05-05/FS05-05-002.pdf\n", "\n", "First, we import `conx` and create a 6-10-2+2 feed-forward network:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from calysto.ai.conx import Network\n", "import random" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "class XorNetwork(Network):\n", " def __init__(self):\n", " super().__init__()\n", " self.totalCorrect = 0\n", " self.totalPossible = 0\n", " self.totalTSSError = 0\n", " \n", " def correct(self, layername):\n", " c = 0\n", " for i in range(len(self[layername].activation)):\n", " if abs(self[layername].activation[i] - self[layername].target[i]) < self.tolerance:\n", " c += 1\n", " return c\n", "\n", " def reportPattern(self):\n", " if (self[\"input\"].activation[0] == 1 and\n", " self[\"input\"].activation[1] == 1):\n", " c = self.correct(\"output\")\n", " self.totalCorrect += c\n", " self.totalPossible += 2\n", " self.totalTSSError += self[\"output\"].TSSError()\n", " \n", " def reportEpoch(self, *args):\n", " print(\"Epoch:\", self.epoch, end=\" \")\n", " print(\"Percent Correct:\", self.totalCorrect/float(self.totalPossible), end=\" \")\n", " print(\"TSS Error:\", self.totalTSSError)\n", " self.totalCorrect = 0\n", " self.totalPossible = 0\n", " self.totalTSSError = 0" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Conx using seed: 1437735633.2086067\n" ] } ], "source": [ "net = XorNetwork()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "net.addLayer(\"input\", 6)\n", "net.addLayer(\"hidden\", 10)\n", "net.addLayer(\"output\", 2)\n", "net.addLayer(\"hints\", 2)\n", "\n", "net.connect(\"input\", \"hidden\")\n", "net.connect(\"hidden\", \"output\")\n", "net.connect(\"hidden\", \"hints\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "net.setTolerance(.4) # outputs must be within this of targets to consider correct\n", "net.setMomentum(0.0)\n", "net.setEpsilon(.6)\n", "net.resetCount = 1\n", "net.resetEpoch = 1000\n", "net.setStopPercent(1.1) # don't stop" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We write a couple of helper functions to generate the inputs and targets:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def bin2list(n, width):\n", " return [int(b) for b in ((\"%0\" + str(width) + \"d\") % int(bin(n)[2:]))]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Test `bin2list`:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[0, 0, 0, 0, 0, 1]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bin2list(1, 6)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def xor(a, b):\n", " return a ^ b" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Test `xor`:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0, 0] : 0\n", "[0, 1] : 1\n", "[1, 0] : 1\n", "[1, 1] : 0\n" ] } ], "source": [ "for group in range(4):\n", " list_group = bin2list(group, 2)\n", " print(list_group, \":\", xor(*list_group))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [], "source": [ "inputs = []\n", "targets = []\n", "for group in range(4):\n", " list_group = bin2list(group, 2)\n", " for i in range(2 ** 4):\n", " list_i = bin2list(i, 4)\n", " inputs.append(list_group + list_i)\n", " targets.append([xor(*list_i[0:2]), xor(*list_i[2:4])] + [0.5, 0.5])\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "(64, 64)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(inputs), len(targets)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ "net.mapTarget(\"output\", 0)\n", "net.mapTarget(\"hints\", 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we are ready to set the inputs and targets and train:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [], "source": [ "net.setInputs(inputs)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [], "source": [ "net.setTargets(targets)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.1 Standard XOR Problem" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Initializing 'Backprop Network' weights... " ] } ], "source": [ "net.initialize()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch: 25 Percent Correct: 0.085 TSS Error: 210.387959588\n", "Epoch: 50 Percent Correct: 0.0825 TSS Error: 206.114479848\n", "Epoch: 75 Percent Correct: 0.42375 TSS Error: 172.805874726\n", "Epoch: 100 Percent Correct: 0.48125 TSS Error: 161.506952252\n", "Epoch: 125 Percent Correct: 0.9725 TSS Error: 20.4823148419\n", "Epoch: 150 Percent Correct: 1.0 TSS Error: 1.61885719386\n", "Epoch: 175 Percent Correct: 1.0 TSS Error: 0.635201165256\n", "Epoch: 200 Percent Correct: 1.0 TSS Error: 0.347357788025\n", "Epoch: 225 Percent Correct: 1.0 TSS Error: 0.224530690366\n", "Epoch: 250 Percent Correct: 1.0 TSS Error: 0.157763387438\n", "Epoch: 275 Percent Correct: 1.0 TSS Error: 0.116869609826\n", "Epoch: 300 Percent Correct: 1.0 TSS Error: 0.0906929986352\n", "Epoch: 325 Percent Correct: 1.0 TSS Error: 0.0724010081715\n", "Epoch: 350 Percent Correct: 1.0 TSS Error: 0.0594036871919\n", "Epoch: 375 Percent Correct: 1.0 TSS Error: 0.0494409150958\n", "Epoch: 400 Percent Correct: 1.0 TSS Error: 0.0419186327269\n", "Epoch: 425 Percent Correct: 1.0 TSS Error: 0.0360186050152\n", "Epoch: 450 Percent Correct: 1.0 TSS Error: 0.0312728817568\n", "Epoch: 475 Percent Correct: 1.0 TSS Error: 0.0274384030386\n", "Epoch: 500 Percent Correct: 1.0 TSS Error: 0.024267839265\n", "Epoch: 525 Percent Correct: 1.0 TSS Error: 0.0216279424131\n", "Epoch: 550 Percent Correct: 1.0 TSS Error: 0.019398309974\n", "Epoch: 575 Percent Correct: 1.0 TSS Error: 0.017496471468\n", "Epoch: 600 Percent Correct: 1.0 TSS Error: 0.0158691034136\n", "Epoch: 625 Percent Correct: 1.0 TSS Error: 0.0144541750188\n", "Epoch: 650 Percent Correct: 1.0 TSS Error: 0.0132248510641\n", "Epoch: 675 Percent Correct: 1.0 TSS Error: 0.0121386998779\n", "Epoch: 700 Percent Correct: 1.0 TSS Error: 0.0112001659546\n", "Epoch: 725 Percent Correct: 1.0 TSS Error: 0.0103599951082\n", "Epoch: 750 Percent Correct: 1.0 TSS Error: 0.00960425529018\n", "Epoch: 775 Percent Correct: 1.0 TSS Error: 0.00893513030208\n", "Epoch: 800 Percent Correct: 1.0 TSS Error: 0.00833198497809\n", "Epoch: 825 Percent Correct: 1.0 TSS Error: 0.00778593751153\n", "Epoch: 850 Percent Correct: 1.0 TSS Error: 0.00729620767092\n", "Epoch: 875 Percent Correct: 1.0 TSS Error: 0.00685148658247\n", "Epoch: 900 Percent Correct: 1.0 TSS Error: 0.0064473166284\n", "Epoch: 925 Percent Correct: 1.0 TSS Error: 0.00607469823391\n", "Epoch: 950 Percent Correct: 1.0 TSS Error: 0.00573633031302\n", "Epoch: 975 Percent Correct: 1.0 TSS Error: 0.0054244256803\n", "Epoch: 1000 Percent Correct: 1.0 TSS Error: 0.00513802981646\n", "Reset limit reached; ending without reaching goal\n", "Final # 1000 | TSS Error: 0.0008 | Correct: 1.0000 | RMS Error: 0.0018\n", " Final # 1000, Layer = 'hints' | Units: 1.0000 | Patterns: 1.0000\n", " Final # 1000, Layer = 'output' | Units: 1.0000 | Patterns: 1.0000\n", "CPU times: user 53.9 s, sys: 0 ns, total: 53.9 s\n", "Wall time: 54.1 s\n" ] } ], "source": [ "%%time\n", "net.train()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Learns the patterns very quickly, usually in less that 100 epochs." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-----------------------------------Pattern # 49\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.50 \n", "Activation: 0.50 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.00 1.00 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 10, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.06 0.23 0.03 0.05 0.17 0.96 0.16 0.10 0.00 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 0.00 0.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 20\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.50 \n", "Activation: 0.50 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.00 0.00 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 10, Active: 1, Frozen: 0)\n", "Activation: 0.13 0.04 0.05 0.90 0.00 0.06 0.00 0.04 0.02 0.89 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: g\n" ] } ], "source": [ "net.interactive = 1\n", "net.sweep()\n", "net.interactive = 0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.2 XOR in Noisy Environment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we will make the task a bit harder by corrupting some patterns so that they cannot be learned:" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def postPropagate(*args, **kwargs):\n", " input_pattern = kwargs[\"input\"]\n", " if input_pattern[:2] in [[0, 0], [0, 1], [1, 0]]:\n", " for i in range(2):\n", " kwargs[\"output\"][i] = random.random() #random.randint(0, 1)\n", " target_pattern = kwargs[\"hints\"]\n", " for i in range(2):\n", " error = net[\"output\"][i].activation - kwargs[\"output\"][i]\n", " target_pattern[i] = abs(error) # max(min((error + 1.0)/2.0, 1.0), 0.0)\n", " return kwargs\n", "\n", "net.postPropagate = postPropagate" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If an input starts with [0,0], [0,1] or [1,0] then we randomly change the targets." ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Initializing 'Backprop Network' weights... " ] } ], "source": [ "net.initialize()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch: 25 Percent Correct: 0.48165760869565216 TSS Error: 207.246010391\n", "Epoch: 50 Percent Correct: 0.015 TSS Error: 207.664382012\n", "Epoch: 75 Percent Correct: 0.0225 TSS Error: 207.731268183\n", "Epoch: 100 Percent Correct: 0.01 TSS Error: 207.819999006\n", "Epoch: 125 Percent Correct: 0.025 TSS Error: 206.749954314\n", "Epoch: 150 Percent Correct: 0.0175 TSS Error: 206.341989881\n", "Epoch: 175 Percent Correct: 0.0175 TSS Error: 207.682095538\n", "Epoch: 200 Percent Correct: 0.0175 TSS Error: 205.65654072\n", "Epoch: 225 Percent Correct: 0.02 TSS Error: 206.406838443\n", "Epoch: 250 Percent Correct: 0.005 TSS Error: 207.952140679\n", "Epoch: 275 Percent Correct: 0.01 TSS Error: 206.11341432\n", "Epoch: 300 Percent Correct: 0.0175 TSS Error: 204.903412577\n", "Epoch: 325 Percent Correct: 0.015 TSS Error: 207.163058142\n", "Epoch: 350 Percent Correct: 0.01375 TSS Error: 205.657379616\n", "Epoch: 375 Percent Correct: 0.02625 TSS Error: 207.758648002\n", "Epoch: 400 Percent Correct: 0.01375 TSS Error: 207.236668269\n", "Epoch: 425 Percent Correct: 0.0125 TSS Error: 207.235352555\n", "Epoch: 450 Percent Correct: 0.025 TSS Error: 206.035634172\n", "Epoch: 475 Percent Correct: 0.015 TSS Error: 206.760542495\n", "Epoch: 500 Percent Correct: 0.0125 TSS Error: 206.189978998\n", "Epoch: 525 Percent Correct: 0.015 TSS Error: 207.130356074\n", "Epoch: 550 Percent Correct: 0.01 TSS Error: 206.163549657\n", "Epoch: 575 Percent Correct: 0.01 TSS Error: 208.295400147\n", "Epoch: 600 Percent Correct: 0.0225 TSS Error: 206.767899701\n", "Epoch: 625 Percent Correct: 0.00875 TSS Error: 206.346999274\n", "Epoch: 650 Percent Correct: 0.0275 TSS Error: 205.569044284\n", "Epoch: 675 Percent Correct: 0.005 TSS Error: 206.188091389\n", "Epoch: 700 Percent Correct: 0.00875 TSS Error: 206.944662583\n", "Epoch: 725 Percent Correct: 0.0275 TSS Error: 206.146348102\n", "Epoch: 750 Percent Correct: 0.01875 TSS Error: 205.71528004\n", "Epoch: 775 Percent Correct: 0.0175 TSS Error: 205.052459473\n", "Epoch: 800 Percent Correct: 0.01875 TSS Error: 205.867722752\n", "Epoch: 825 Percent Correct: 0.0175 TSS Error: 208.033197286\n", "Epoch: 850 Percent Correct: 0.015 TSS Error: 207.366018869\n", "Epoch: 875 Percent Correct: 0.0075 TSS Error: 206.100793193\n", "Epoch: 900 Percent Correct: 0.0175 TSS Error: 206.240182651\n", "Epoch: 925 Percent Correct: 0.02125 TSS Error: 206.969226552\n", "Epoch: 950 Percent Correct: 0.0125 TSS Error: 206.842018432\n", "Epoch: 975 Percent Correct: 0.025 TSS Error: 205.948221626\n", "Epoch: 1000 Percent Correct: 0.02 TSS Error: 205.373884697\n", "Reset limit reached; ending without reaching goal\n", "Final # 1000 | TSS Error: 18.5024 | Correct: 0.8047 | RMS Error: 0.2688\n", " Final # 1000, Layer = 'hints' | Units: 1.0000 | Patterns: 1.0000\n", " Final # 1000, Layer = 'output' | Units: 0.6094 | Patterns: 0.4531\n", "CPU times: user 55.6 s, sys: 3.91 ms, total: 55.6 s\n", "Wall time: 55.6 s\n" ] } ], "source": [ "%%time\n", "net.train()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Standard backprop cannot learn the pattern in over 3k+ epochs." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-----------------------------------Pattern # 44\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.55 0.37 \n", "Activation: 0.51 0.48 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.55 0.37 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.03 0.02 0.02 0.02 0.02 0.02 0.02 0.23 0.01 0.02 0.02 0.02 0.02 0.02 0.04 0.02 0.02 0.02 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 1.00 0.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 57\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.48 0.28 \n", "Activation: 0.51 0.45 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.52 0.28 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.01 0.00 0.01 0.01 0.01 0.01 0.02 0.01 0.41 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.00 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 0.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 29\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.46 0.47 \n", "Activation: 0.51 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.54 0.47 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02 0.02 0.02 0.02 0.02 0.03 0.02 0.02 0.02 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 1.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 28\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.44 0.47 \n", "Activation: 0.51 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.56 0.47 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 0.00 1.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 27\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.58 0.57 \n", "Activation: 0.50 0.49 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.58 0.43 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.04 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 1.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 22\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.55 0.40 \n", "Activation: 0.51 0.48 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.55 0.40 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.13 0.01 0.01 0.01 0.01 0.01 0.01 0.02 0.01 0.01 0.01 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 1.00 1.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 51\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.54 0.44 \n", "Activation: 0.51 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.54 0.44 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.01 0.00 0.00 0.00 0.00 0.01 0.00 0.03 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 1.00 1.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 36\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.60 \n", "Activation: 0.51 0.49 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.50 0.40 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.02 0.02 0.02 0.01 0.02 0.04 0.02 0.07 0.02 0.02 0.03 0.01 0.01 0.03 0.03 0.02 0.02 0.01 0.05 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 0.00 0.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 55\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.46 \n", "Activation: 0.51 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.50 0.46 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.02 0.01 0.01 0.01 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 1.00 1.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 34\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.52 0.74 \n", "Activation: 0.51 0.45 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.52 0.26 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.36 0.02 0.02 0.02 0.02 0.02 0.02 0.04 0.02 0.02 0.02 0.03 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 0.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 11\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.54 \n", "Activation: 0.51 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.50 0.46 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.02 0.00 0.00 0.01 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 1.00 1.00 1.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 53\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.54 0.48 \n", "Activation: 0.51 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.46 0.48 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.04 0.04 0.04 0.04 0.04 0.04 0.05 0.04 0.02 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.05 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 52\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.32 \n", "Activation: 0.51 0.47 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.50 0.32 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.29 0.00 0.00 0.01 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 19\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.52 0.58 \n", "Activation: 0.51 0.49 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.48 0.42 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.01 0.00 0.01 0.02 0.00 0.08 0.00 0.01 0.01 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 0.00 1.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 38\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.50 0.46 \n", "Activation: 0.51 0.50 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.50 0.46 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.01 0.01 0.01 0.01 0.01 0.01 0.02 0.01 0.04 0.01 0.01 0.01 0.01 0.01 0.01 0.02 0.01 0.01 0.01 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 1.00 0.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 49\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.53 0.72 \n", "Activation: 0.51 0.46 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.47 0.28 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.04 0.05 0.04 0.04 0.04 0.04 0.06 0.04 0.34 0.04 0.04 0.05 0.04 0.04 0.05 0.05 0.04 0.04 0.04 0.06 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 0.00 0.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 17\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.47 0.62 \n", "Activation: 0.51 0.49 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 1.00 \n", "Activation: 0.47 0.38 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.03 0.02 0.05 0.04 0.04 0.06 0.07 0.03 0.19 0.05 0.06 0.05 0.03 0.03 0.06 0.04 0.04 0.04 0.03 0.09 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 1.00 0.00 0.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 46\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.52 0.50 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.48 0.50 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.01 0.02 0.02 0.01 0.02 0.03 0.02 0.02 0.02 0.02 0.02 0.01 0.02 0.02 0.03 0.02 0.02 0.01 0.03 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 1.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 6\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.52 0.49 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.48 0.51 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.04 0.03 0.04 0.05 0.04 0.05 0.06 0.04 0.02 0.04 0.05 0.05 0.03 0.03 0.05 0.04 0.04 0.04 0.03 0.07 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 60\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.49 0.46 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.51 0.54 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.01 0.02 0.02 0.02 0.02 0.03 0.02 0.00 0.02 0.02 0.02 0.01 0.01 0.02 0.02 0.02 0.02 0.01 0.04 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 1.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 7\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.52 0.55 \n", "Activation: 0.51 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.52 0.55 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.01 0.02 0.02 0.02 0.03 0.04 0.01 0.02 0.02 0.03 0.02 0.01 0.01 0.03 0.02 0.02 0.02 0.01 0.05 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 1.00 0.00 0.00 0.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 50\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.48 0.54 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.52 0.54 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 0.00 1.00 1.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 21\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.46 0.52 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.54 0.52 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 0.00 0.00 1.00 1.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 40\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.45 0.51 \n", "Activation: 0.51 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.55 0.49 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.01 0.00 0.01 0.01 0.01 0.01 0.02 0.01 0.02 0.01 0.01 0.01 0.00 0.01 0.01 0.01 0.01 0.01 0.00 0.03 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 1.00 0.00 1.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 10\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.57 0.52 \n", "Activation: 0.50 0.52 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.00 0.00 \n", "Activation: 0.57 0.52 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 1.00 1.00 1.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 25\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.45 0.52 \n", "Activation: 0.51 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.55 0.48 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 0.00 0.01 0.00 0.01 0.01 0.00 0.05 0.00 0.01 0.01 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.02 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 1.00 1.00 1.00 0.00 1.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 61\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.43 0.53 \n", "Activation: 0.51 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 1.00 \n", "Activation: 0.57 0.47 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.02 0.03 0.02 0.02 0.02 0.01 0.01 0.02 0.09 0.02 0.01 0.02 0.02 0.02 0.02 0.04 0.02 0.02 0.02 0.01 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 1.00 1.00 0.00 0.00 \n", "uit, o, or press Enter: \n", "-----------------------------------Pattern # 14\n", "Display network 'Backprop Network':\n", "=============================\n", "Layer 'hints': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 0.42 0.48 \n", "Activation: 0.50 0.51 \n", "=============================\n", "Layer 'output': (Kind: Output, Size: 2, Active: 1, Frozen: 0)\n", "Target : 1.00 0.00 \n", "Activation: 0.58 0.48 \n", "=============================\n", "Layer 'hidden': (Kind: Hidden, Size: 20, Active: 1, Frozen: 0)\n", "Activation: 0.04 0.07 0.04 0.04 0.04 0.03 0.03 0.05 0.09 0.03 0.03 0.04 0.04 0.04 0.04 0.06 0.04 0.04 0.05 0.03 \n", "=============================\n", "Layer 'input': (Kind: Input, Size: 6, Active: 1, Frozen: 0)\n", "Activation: 0.00 0.00 1.00 0.00 0.00 0.00 \n" ] } ], "source": [ "net.interactive = 1\n", "net.sweep()\n", "net.interactive = 0" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "
\n", "\n", "This is a test.\n", "\n", "
\n", "\n", "
\n", "\n", "This is a test.\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.0" } }, "nbformat": 4, "nbformat_minor": 0 }